<?php
/**
 * Created by PhpStorm.
 * User: yzapple
 * Date: 2018/1/10
 * Time: 下午5:12
 */
namespace app\common\validate;

use think\Validate;

class Patient extends Validate
{

    protected $rule =   [
        'name'  => 'require|max:25',
        'document_num'   => 'require|unique:patient',
        'birth' => 'require',
        'phone'     => 'require|length:11|/^1[34578]\d{9}$/',

    ];

    protected $message  =   [
        'name.require' => '姓名必填',
        'name.max'     => '姓名最多不能超过25个字符',
        'document_num.require'   => '证件号必填',
       'document_num.unique'   => '证件号已存在',
        'birth'        => '出生日期必填',
        'phone.require'     => '手机号必填',
        'phone.length'   => '手机号格式不正确',
        'phone./^1[34578]\d{9}$/'   => '手机号格式不正确',


    ];
    //场景不同场景验证不同的字段
    protected $scene = [
        'add_patient'    => ['name','document_num','birth','phone'],
        'edit_patient' => ['name','document_num','birth','phone'],
    ];
}